package com.mzj.saas.mservice.backlog.repository;

import com.mzj.saas.mservice.backlog.entity.BacklogItem;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface BacklogItemRepository extends PagingAndSortingRepository<BacklogItem, Long>, JpaSpecificationExecutor<BacklogItem> {

    @Query("from BacklogItem  where houseId=?1 and type=?2 and DATE_FORMAT(create_time, '%Y-%m-%d') = ?3")
    BacklogItem findByHouseIdAndType(String houseId, Integer type, String date);

    @Query("from BacklogItem  where houseId=?1 and type=?2 and match_user_id=?3")
    BacklogItem findByHouseIdAndTypeAndMatchUserId(String houseId, Integer type, String userId);

    List<BacklogItem> findByHouseIdAndTypeAndHandleStatus(String houseId, Integer type, Integer handleStatus);

    List<BacklogItem> findByMatchUserId(String matchUserId);

    int deleteByIdIn(List<Long> ids);

    BacklogItem findByHouseIdAndMatchUserIdAndType(String houseId, String matchUserId, Integer type);
    BacklogItem findByIdAndPhone(Long Id, String phone);

    int deleteByHouseIdAndType(String houseId, Integer type);

    int deleteByHouseIdAndTypeAndMatchUserId(String communityHouseId, Integer type, String matchUserId);
}
